<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.0/dist/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js">
    </script>
</head>
<body>
<div class="container">
    <form action="/search/good">
        <input type="text" name="goods_type" value="{$Request.param.goods_type}">
        <input type="submit" value="搜索">
    </form>
    <button class="add">商品添加</button>
    <table class="table">
        <thead>
        <tr>
            <th scope="col">#</th>
            <th scope="col">商品</th>
            <th scope="col">商品分类</th>
            <th scope="col">商品数量</th>
            <th scope="col">商品库存</th>
            <th scope="col">售价</th>
            <th scope="col">所属商家</th>
            <th scope="col">发布时间</th>
            <th scope="col">操作</th>
        </tr>
        </thead>
        <tbody>
        {volist name="data" id="v"}
        <tr>
            <td>{$v.id}</td>
            <td>
                <img src="/{$v.pic}">
                {$v.goods_name}
                <a href="/crop/pic?url={$v.pic}">裁剪</a>
            </td>
            <td>{$v.goods_type}</td>
            <td>{$v.number}</td>
            <td>{$v.count}</td>
            <td>{$v.price}</td>
            <td>{$v.business}</td>
            <td>{$v.addtime}</td>
            <td>
                <button class="crop">裁剪</button>
                <button class="del">删除</button>
            </td>
        </tr>
        {/volist}
        </tbody>
    </table>
    {$data->render()}
</div>
</body>
</html>
<script>

    $(".del").on('click',function () {
        let id= $(this).parents("tr").children("td:eq(0)").text();
        let that = this;
        $.ajax({
            url:"http://www.w2.com/goodss/"+id,
            method:"delete",
            success:function (res){
                alert(res.msg);
                $(that).parents('tr').remove();
            }
        })
    })

    $(".add").on('click',function () {
       window.location.href="http://www.w2.com/goodss/create";
    })
</script>